package com.example.b_308.software.view.main.message;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.example.b_308.software.R;
import com.example.b_308.software.controller.message.MessageController;
import com.example.b_308.software.model.MessageModel;
import com.example.b_308.software.view.BaseFragment;

import java.util.List;

/**
 * Created by B-308 on 2017/11/21.
 */
public  class MessageFragment extends BaseFragment implements IMessageView{
    ListView lv_message;
    MessageAdapter messageAdapter;
    MessageController messageController;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.fragment_message,null);
        lv_message= (ListView) view.findViewById(R.id.lv_message);
        messageController=new MessageController(this);
        messageController.getList();


        return view;
    }

    @Override
    public View setContentView(LayoutInflater inflater) {
        return null;
    }

    @Override
    public void initData() {

    }

    @Override
    public void initView() {

    }

    @Override
    public void initListener() {

    }

    @Override
    public void onRequestListSuccess(List<MessageModel> messageModel) {

        if(null!=messageAdapter){
            messageAdapter.notifyChange(messageModel);
        }else{
            messageAdapter = new MessageAdapter(messageModel,getActivity());
        }

        lv_message.setAdapter(messageAdapter);


    }
}
